Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Affected Issue(s): Add some helpful views for data analytics #150

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

muhammad-levi
Copy link

@muhammad-levi muhammad-levi commented Sep 15, 2022

What this commit has achieved:

  1. Created some functions to generate views
  2. Inspired by
    https://stackoverflow.com/a/35179515,
    https://stackoverflow.com/a/54290549,
    and the motivation to do so by
    https://ellisvalentiner.com/post/2022-01-06-flattening-json-in-postgres/
  3. TODO maybe add these scripts into the MyBatis migrations

Preview
image

What this commit has achieved:
1. Created some functions to generate views
2. Inspired by
https://stackoverflow.com/a/35179515,
https://stackoverflow.com/a/54290549,

and the motivation to do so by
https://ellisvalentiner.com/post/2022-01-06-flattening-json-in-postgres/
3. TODO maybe add these scripts into the MyBatis migrations
@muhammad-levi muhammad-levi changed the title Affected Issue(s): Add views for data analytics Affected Issue(s): Add some helpful views for data analytics Sep 15, 2022
What this commit has achieved:
1. Add `client_detailed_view` for OpenSRP-Client-ANC
What this commit has achieved:
1. Created a function to create jsonb flat view with capability of flattening nested object(s)
What this commit has achieved:
1. Reorder the nested column names
2. Deselect root property `obs`, as the flat array already selected
What this commit has achieved:
1. Deselect column `e."json"->>'details' "details"` because flattened already.
https://www.notion.so/sid-levi/SysAdmin-Automate-generate_all_event_type_views-of-Bunda-App-data-0db0372bcb824c5595f2780f85202da3

What this commit has achieved:
1. Removed all "ORDER BY" in the view, let user to order lastly
2. Created indexes to optimize the query plan
https://www.notion.so/sid-levi/SysAdmin-Automate-generate_all_event_type_views-of-Bunda-App-data-0db0372bcb824c5595f2780f85202da3

What this commit has achieved:
1. Removed `opensrp-client-anc_client-detailed-view.sql`
2. Can use `create_jsonb_nested_flat_view` function to achieve the same
```
core.create_jsonb_nested_flat_view(
    'client',
    'id, date_deleted, server_version',
    'json',
    'identifiers', 'attributes'
);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant